package net.flyinggroup.client;

import net.flyinggroup.client.repository.CountryRepository;
import net.flyinggroup.client.service.CountryClient;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class ClientApplication {
    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(CountryClient countryClient, CountryRepository countryRepository) {
        return args -> countryClient.getCountries()
                .subscribe(countryRepository::saveAll);
    }
}
